<?php

if( $this->needClose )
    $needClose='true';
else
    $needClose='false';

$this->headLink(array('href' => '/cms/styles/style.css', 'rel' => "stylesheet", 'type' => "text/css"));
$this->headLink(array('href' => '/cms/styles/data-table.css', 'rel' => "stylesheet", 'type' => "text/css"));
$this->headLink(array('href' => '/cms/styles/popupMenu.css', 'rel' => "stylesheet", 'type' => "text/css"));
    
$this->headScript()
	->appendFile('/cms/scripts/dojo/dojo.js','',array('djConfig'=> 'parseOnLoad:true, isDebug:false'))
	->setAllowArbitraryAttributes(true);

$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/shadowbox/build/adapter/shadowbox-base.js');
$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/shadowbox/build/shadowbox.js');

$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/content.js');
$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/Popup.js');
$this->headScript(Zend_View_Helper_HeadScript::FILE,'/cms/scripts/TableData.js');
$this->headScript(Zend_View_Helper_HeadScript::SCRIPT,<<<EOD

dojo.require("dojo.fx");
dojo.require("dijit.Dialog");

var boxes = new Array();

var needClose = {$needClose};

var shadowbox_callback = function () {};

reset_shadowbox_callback = function () {
	shadowbox_callback = function () {};
}

window.onload = function () {
    recountRate();
    if( needClose == true ) window.parent.setTimeout('Shadowbox.close()',10);        
}

Shadowbox.loadSkin('classic', '/cms/scripts/shadowbox/src/skin');
Shadowbox.loadLanguage('ru', '/cms/scripts/shadowbox/build/lang');
Shadowbox.loadPlayer(['html', 'iframe', 'img', 'swf'], '/cms/scripts/shadowbox/build/player');

var currentRate = {$this->rating->score};
var currentAmount = {$this->rating->voites};
function recountRate() {

	var scoreVal = parseFloat(document.getElementById('score').value);
	var amountVal = parseInt(document.getElementById('amount').value);
	var newScore = (( currentRate*currentAmount + scoreVal*amountVal ) / ( currentAmount + amountVal )).toString();
	if (newScore=='NaN') {
		newScore = 'Неверно введенное значение';
	} else {
		newScore = newScore.toString().split('.');
		if (typeof newScore[1] !== 'undefined') {
			newScore[1] = newScore[1].substr(0,2);
		}
		newScore = newScore.join('.');
	}
	document.getElementById('resultScore').innerHTML = newScore;
	document.getElementById('newscore').value = newScore;
}
EOD
);?>
</head>

<body class="modal">
<form id="form1" name="form1" method="post" action="">
  <table border="0" cellpadding="0" cellspacing="0" class="form">
    <tr>
      <td class="lablel">Текущий рейтинг:</td>
      <td valign="bottom" class="stnd_font"><?=$this->rating->score?></td>
    </tr>
    <tr>
      <td class="lablel">Оценка:</td>
      <td><input name="score" type="text" class="modalInput" id="score" value="3" onkeyup="recountRate()" />
<!--        <ul class="errors" style='display:none'>
          <li>Неверный формат</li>
        </ul>-->
        </td>
    </tr>
    <tr>
      <td class="lablel">Количество:</td>
      <td><input name="amount" type="text" class="modalInput" id="amount" value="1" onkeyup="recountRate()"/></td>
    </tr>
    
    <tr>
      <td class="lablel">Результат:</td>
      <td valign="bottom" class="stnd_font"><div id="resultScore">4.1</div>
      <input type='hidden' id='newscore' name='newscore' value='4.1' \>
      
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" class="okButton" name='ok' id="okButton" value="Добавить" />
          <input type="button" class="okButton" value="Отмена" onclick="window.parent.setTimeout('Shadowbox.close()',10)" /></td>
    </tr>
  </table>
</form>
</body>
</html>
